<script lang="ts" setup>
import { ref } from 'vue';
import {showToast} from 'vant';
import { useRouter } from 'vue-router';
const router = useRouter();


import Utils from "../../../req/Utils";

const props = defineProps({
  obj: {
    type: Object
  }
});

const currentData = ref<any>({
  statusArr: ["已签收","派送中","已取消"]
});

const addProduct = () => {
  Utils.clearCart();
  let productList = props.obj.orderDetailList
  for(let i = 0;  i<productList.length; i++) {
    let num = productList[i].productQuantity;
    for(let j = 0;  j<num; j++) {
      Utils.addCart(productList[i]);
    }
  }
  showToast("添加购物车成功")
  router.push("/cart");
}

</script>
<template>
  <section class="orderStatusUtil">
    <div class="item"><span>订单状态：</span>{{currentData.statusArr[props.obj.orderStatus]}}</div>
    <div class="item"><span>订单编号：</span>{{props.obj.orderId}}</div>
    <div class="item"><span>下单时间：</span>2018-07-24 10:13:57</div>
    <div class="btn-wrap">
      <div class="btn" @click="addProduct">再次购买</div>
    </div>
  </section>
</template>

<style lang="less" scoped>
.orderStatusUtil {
  width: 3.75rem;
  padding: .1rem;
  background: white;
  box-sizing: border-box;
  margin-bottom: .15rem;
  .item {
    font-size: .14rem;
    line-height: .21rem;
    color: #151515;
    span {
      color: #999;
    }
  }
  
  .btn-wrap {
    padding-top: .2rem;
    .btn {
      width: 3.55rem;
      height: 46px;
      line-height: 46px;
      margin: 0 auto;
      background: #e93b3d;
      color: white;
      text-align: center;
      font-size: 16px;
      border-radius: 4px;
    }
  }
}
</style>

